#!/bin/bash
test_stream(){
    if [[ -n "$install_stream_dir" || -d "$install_stream_dir" ]];then
        pushd $install_stream_dir
        if [[ -z "$sum_stream" ]];then
            sum_stream=3
        fi
        rm -rf $stream_log_path
        mkdir -p $stream_log_path
        if [[ -e "./stream" ]];then
            rm -f stream-*.log
            red_z_green_z "正在进行stream测试:" "单线程测试" 
            # 设置性能模式
            cpupower -c all frequency-set -g performance
            # 进行单线程测试
            export OMP_NUM_THREADS=1
            export GOMP_CPU_AFFINITY=0
            for((i=1;i<=${sum_stream};i++));do
                ./stream taskset –c 0 ./stream | tee –a ${stream_log_path}/stream-single${i}.log
            done

        
            # 进行多线程测试
            export OMP_NUM_THREADS=`cat /proc/cpuinfo  | grep pro | wc -l`
            end_cpu=$((`cat /proc/cpuinfo  | grep pro | wc -l`-1))
            export GOMP_CPU_AFFINITY=0-${end_cpu}
            for((i=1;i<=${sum_stream};i++));do
                ./stream taskset –c 0-${end_cpu} ./stream | tee –a ${stream_log_path}/stream-multi${i}.log
            done
        else
            red_bg "找不到文件: `pwd`/stream"
        fi
    else
        red_bg "找不到路径: $install_stream_dir"
    fi
}